﻿#ifndef UIDOWNLOAD_H
#define UIDOWNLOAD_H

#include <QWidget>
#include <QJsonObject>

namespace Ui
{
    class UiDownload;
}

class UiProgressWidget;

/// @brief 传输进度界面的子界面(下载)
///
class UiDownload: public QWidget
{
    Q_OBJECT

private:
    Ui::UiDownload* ui;

public:
    explicit UiDownload(QWidget* parent = nullptr);
    ~UiDownload();

private slots:
    void onStartDownload(
            const QString& jobId,
            const QString& key,
            const QString& localPath,
            qulonglong total);
    void onDownloadProcess(
            const QString& jobId,
            qulonglong transferedSize,
            qulonglong totalSize);
    void onDownloadSuccess(const QString& jobId);
    void onError(int api, const QString& msg, const QJsonValue& req);

private:
    UiProgressWidget* findTableWidgetItem(const QString& jobId);
    void initHeader();
};

#endif // UIDOWNLOAD_H
